<?php
 require_once('../Connections/mlu.php');
 ?>

<script type="text/javascript">
function checkprezzo(){
		
		$('#index').append('<div id="prezzoinfo" class="info"></div>');
    	var prezzoInfo = $('#prezzoinfo');
		var ele = $('#prezzo');
		var pos = ele.offset();
		
		prezzoInfo.css({
			top: pos.top-3,
			left: pos.left+ele.width()+15
		});
		
		var prezzocifre = /^[0-9]{1,3}\.[0-9]{2}$/i;
		
		if(!prezzocifre.test(ele.val())) {
				prezzoInfo.removeClass('correct').addClass('error').html('&larr; Il prezzo &egrave; da inserire con il punto!<br>Inoltre dopo il punto mettere 2 cifre<br>Es:<i>12<u>.</u>34</i>').show();
				ele.removeClass('normal').addClass('wrong');					
		} else {
				prezzoInfo.removeClass('error').addClass('correct').html('&radic;').show();
				ele.removeClass('wrong').addClass('normal');
		}	
}
</script>
<?php


$query_Recordset1 = "SELECT * FROM materie order by nomemateria";
$Recordset1 = mysql_query($query_Recordset1, $mlu) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

$query_Recordset2 = "SELECT * FROM libri WHERE codiceean=". $_GET['mod'];
$Recordset2 = mysql_query($query_Recordset2, $mlu) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?>
    	<form action="/mlu/libri/salva.php" method="post" name="formtitolo" id="formtitolo">
  <table align="center">
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">codice libro:</td>
      <td><label for="codiceean"></label>
        <input name="codiceean" type="text" id="codiceean" readonly="readonly" value="<?php echo $row_Recordset2['codiceEAN']; ?>"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Titolo:</td>
      <td><input type="text" name="titolo" value="<?php echo $row_Recordset2['titolo']; ?>" size="32" id="titolo"/></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Autori</td>
      <td><input type="text" name="autori" value="<?php echo $row_Recordset2['autore']; ?>" size="32" id="autori"/></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Casa Editrice</td>
      <td><input type="text" name="casa" value="<?php echo $row_Recordset2['home']; ?>" size="32" id="casa"/></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Prezzo</td>
      <td><input type="text" name="prezzo" value="<?php echo $row_Recordset2['prezzo']; ?>" size="32" id="prezzo"/></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Anno</td>
      <td><input type="text" name="anno" value="<?php echo $row_Recordset2['anno']; ?>" size="32" id="anno"/></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Materia:</td>
      <td><select name="materia">
        <?php 
do {  
?>
        <option value="<?php echo $row_Recordset1['idmateria']?>" <?php if (!(strcmp($row_Recordset1['idmateria'], $row_Recordset2['idmateria']))) {echo "SELECTED";} ?>><?php echo $row_Recordset1['nomemateria']?></option>
        <?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
?>
      </select></td>
    </tr>
    <tr> </tr>
      </table>
      <input name="invia dati" type="submit" id="send" value="invia dati" />
</form>

    
